<template>
  <div class="dispatch common-tabs-wrapper">
    <el-form class="order-search" size="small">
      <el-row type="flex">
        <el-form-item style="width: 130px" prop="cj">
          <el-select v-model="search.cj" clearable @change="getData">
            <template #prefix>车间：</template>
            <el-option
              v-for="item in cjOption"
              :key="item.id"
              :label="item['key_value']"
              :value="item['key_value']"
            />
          </el-select>
        </el-form-item>
        <el-form-item style="width: 130px" prop="org">
          <el-select v-model="search.bc" clearable @change="getData">
            <template #prefix>班次： </template>
            <el-option
              v-for="item in bcOption"
              :key="item.id"
              :label="item['key_value']"
              :value="item['key_value']"
            />
          </el-select>
        </el-form-item>
        <el-form-item class="order-w" style="width: 150px" prop="pz">
          <el-select v-model="search.gongxu" clearable @change="getData">
            <template #prefix>工序： </template>
            <el-option
              v-for="item in gxOption"
              :key="item.id"
              :label="item['key_value']"
              :value="item['key_value']"
            />
          </el-select>
        </el-form-item>
      </el-row>
    </el-form>
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="人员" name="person">
        <person ref="person" :selectSearch="search" @change="changeSearch" />
      </el-tab-pane>
      <el-tab-pane label="工序工种" name="work">
        <work />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import person from './modules/components/person.vue';
import work from './modules/components/work.vue';
export default {
  components: { person, work },
  data() {
    return {
      activeName: 'person',
      search: {
        cj: '',
        bc: '',
        gongxu: '',
        group: '',
        org: '',
        workType: ''
      }
    };
  },
  computed: {
    cjOption() {
      return this.$store.getters.cjOption;
    },
    bcOption() {
      return this.$store.getters.bcOption;
    },
    gxOption() {
      return this.$store.getters.gxOption;
    }
  },
  methods: {
    getData() {
      this.$refs['person'].getTableData(true);
    },
    changeSearch(val) {
      this.search = val;
    }
  }
};
</script>
<style lang="scss">
@import '~@/assets/css/dispatch.scss';
</style>
